n = int(input())
data = list(map(int,input().split(" ")))
for d in data:
    t = bin(d)
    print(t.count('1'),end=' ')


import sys
n = int(input())


data = list(map(int,sys.stdin.readline().split()))

def lowbit(x):
    return x & - x


for d in data:
    res = 0
    while d > 0:
        d -= lowbit(d)
        res+=1
    print(res,end=' ')
